using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;

namespace AvaAI批量点评系统.Views
{
    /// <summary>
    /// 将选中的等级转换为对应的背景颜色
    /// </summary>
    public class LevelToColorConverter : IValueConverter
    {
        public static readonly LevelToColorConverter Instance = new();

        public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            var selectedLevel = value?.ToString();
            var currentLevel = parameter?.ToString();

            // 如果当前等级是选中的等级，返回高亮颜色
            if (selectedLevel == currentLevel)
            {
                return currentLevel switch
                {
                    "A-" => Color.FromRgb(255, 235, 235), // 浅红色
                    "A" => Color.FromRgb(235, 255, 235),  // 浅绿色
                    "A+" => Color.FromRgb(235, 235, 255), // 浅蓝色
                    _ => Colors.White
                };
            }

            // 未选中的等级返回白色
            return Colors.White;
        }

        public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
